define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'datacenter/xiaoqu/index',
                    add_url: 'datacenter/xiaoqu/add',
                    edit_url: 'datacenter/xiaoqu/edit',
                    del_url: 'datacenter/xiaoqu/del',
                    multi_url: 'datacenter/xiaoqu/multi',
                    table: 'xiaoqu',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'wuye_id', title: __('Wuye_id')},
                        {field: 'wuye_name', title: __('Wuye_name')},
                        {field: 'hotline', title: __('Hotline')},
                        {field: 'wuye_address', title: __('Wuye_address')},
                        {field: 'community_name', title: __('Community_name')},
                        {field: 'community_city', title: __('Community_city')},
                        {field: 'community_address', title: __('Community_address')},
                        {field: 'community_locations', title: __('Community_locations')},
                        {field: 'associated_pois', title: __('Associated_pois')},
                        {field: 'out_community_id', title: __('Out_community_id')},
                        {field: 'property_price', title: __('Property_price'), operate:'BETWEEN'},
                        {field: 'water_price', title: __('Water_price'), operate:'BETWEEN'},
                        {field: 'electric_price', title: __('Electric_price'), operate:'BETWEEN'},
                        {field: 'gas_price', title: __('Gas_price'), operate:'BETWEEN'},
                        {field: 'park_price', title: __('Park_price'), operate:'BETWEEN'},
                        {field: 'status', title: __('Status'), visible:false, searchList: {"0":__('Status 0'),"1":__('Status 1')}},
                        {field: 'status_text', title: __('Status'), operate:false},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                pagination: false,
                search: false,
                commonSearch: false,

            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});